Skip to content

refactor: 호스트&티켓 페이지 리팩토링#219

Merged
Yejiin21 merged 7 commits intodevelopfrom
refactor/#215/host-ticket-refac
Jul 6, 2025
Merged

refactor: 호스트&티켓 페이지 리팩토링#219
Yejiin21 merged 7 commits intodevelopfrom
refactor/#215/host-ticket-refac

Conversation

@Yejiin21
Copy link
Copy Markdown
Contributor

@Yejiin21 Yejiin21 commented Jul 6, 2025

Summary by CodeRabbit

  • 신규 기능

    • 호스트 채널 정보 수정 폼, 호스트 정보 표시, 멤버 초대 컴포넌트가 추가되었습니다.
    • 티켓 정보에 구매 가능 기간(시작일/종료일) 표시가 추가되었습니다.
  • 개선 및 변경

    • 마이호스트 정보 수정 페이지가 컴포넌트 기반으로 리팩터링되어 관리가 쉬워졌습니다.
    • 북마크 리스트에서 데이터 정렬 로직이 단순화되었습니다.
    • 기본 프로필 이미지 처리 방식이 변경되었습니다.
  • 버그 수정

    • 폼 유효성 검사 메시지에 쉼표가 추가되어 가독성이 개선되었습니다.
  • 기타

    • 티켓 정보 인터페이스에 시작일과 종료일 필드가 추가되었습니다.
    • 호스트 생성 페이지에서 언마운트 시 상태가 초기화됩니다.

@Yejiin21 Yejiin21 requested review from hyeeuncho and xaexunxang July 6, 2025 13:06
@Yejiin21 Yejiin21 self-assigned this Jul 6, 2025
@Yejiin21 Yejiin21 added the 🪄 Refactoring 코드 리팩토링 label Jul 6, 2025
@Yejiin21 Yejiin21 linked an issue Jul 6, 2025 that may be closed by this pull request
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Jul 6, 2025

Walkthrough

호스트 정보 편집 및 멤버 초대 UI가 컴포넌트(HostEditForm, HostInfo, MemberInvite)로 분리되어 도입되었으며, 관련 훅과 타입, 폼 검증 스키마가 확장되었습니다. 티켓 정보 UI에는 구매 가능 기간 표시가 추가되었고, 프로필 이미지 기본값 처리와 상태 초기화 로직도 일부 변경되었습니다.

Changes

파일/경로 요약 변경 내용 요약
src/entities/host/ui/HostEditForm.tsx
src/entities/host/ui/HostInfo.tsx
src/entities/host/ui/MemberInvite.tsx
호스트 정보 편집, 정보 표시, 멤버 초대용 신규 React 컴포넌트 추가
src/pages/menu/ui/myHost/HostEditPage.tsx 호스트 정보/멤버 초대/편집 UI를 외부 컴포넌트로 분리, 페이지 내 상태 및 JSX 정리
src/features/host/hook/useHostInfoHook.ts useHostInfoSave 훅 시그니처에 email 파라미터 추가, email 저장 방식 변경
src/shared/lib/formValidation.ts 이메일만 검증하는 hostInfoSchema 추가 및 내보내기, 전화번호 에러 메시지 쉼표 추가
src/features/ticket/model/ticketInformation.ts ReadTicketResponse 타입에 startDate, endDate 필드 추가
src/widgets/event/ui/TicketInfo.tsx 티켓 구매 가능 기간(시작/종료일)과 시계 아이콘 표시 UI 추가
src/pages/event/ui/host/HostCreationPage.tsx 기본 프로필 이미지 import 제거, 언마운트 시 호스트 상태 초기화 로직 추가
src/shared/hooks/useImageUpload.ts 기본 프로필 이미지 URL 상수 제거, 로컬 이미지 import로 대체
src/entities/user/ui/BookmarkList.tsx 북마크 리스트 정렬 로직 제거, 데이터 없을 시 null 반환으로 단순화

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant HostEditPage
    participant HostEditForm
    participant useHostChannelInfo
    participant useHostInfoSave

    User->>HostEditPage: "정보 수정" 탭 클릭
    HostEditPage->>HostEditForm: 렌더링
    HostEditForm->>useHostChannelInfo: 채널 정보 fetch
    useHostChannelInfo-->>HostEditForm: hostInfo 반환
    User->>HostEditForm: 이메일/설명 입력, 저장 클릭
    HostEditForm->>useHostInfoSave: email, description 전달하여 저장
    useHostInfoSave-->>HostEditForm: 저장 결과 반환
Loading
sequenceDiagram
    participant User
    participant HostEditPage
    participant MemberInvite

    User->>HostEditPage: "멤버 초대" 탭 클릭
    HostEditPage->>MemberInvite: 렌더링
    User->>MemberInvite: 이메일 입력, "전송" 클릭
    MemberInvite->>HostEditPage: handleInviteMembers 호출
Loading

Possibly related PRs

Suggested reviewers

  • xaexunxang
  • hyeeuncho

Poem

🐇
폼도 나누고, 멤버도 초대
호스트 정보 깔끔하게 새로워졌네
티켓엔 시계가 똑딱똑딱
기본 프로필도 귀엽게 바뀌었지
토끼는 깡총, 코드를 축하해!
🎉

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown
Contributor

@xaexunxang xaexunxang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

고생하셨흡니다요

@github-actions
Copy link
Copy Markdown

github-actions bot commented Jul 6, 2025

@Yejiin21 Yejiin21 merged commit ad15600 into develop Jul 6, 2025
1 of 2 checks passed
@Yejiin21 Yejiin21 deleted the refactor/#215/host-ticket-refac branch July 6, 2025 13:08
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

🧹 Nitpick comments (3)
src/widgets/event/ui/TicketInfo.tsx (1)

88-90: 코드 포맷팅을 정리해주세요.

불필요한 주석과 공백이 있어 코드 가독성이 떨어집니다.

다음과 같이 정리하는 것을 권장합니다:

-            <div className="flex  flex-col gap-2">
-              {' '}
-              {/*  w-[230px]  */}
+            <div className="flex flex-col gap-2">
src/entities/host/ui/HostEditForm.tsx (1)

22-25: 초기화 시점의 안전성 확보

hostInfoundefined일 때도 안전하게 처리되도록 하는 것이 좋습니다.

  useEffect(() => {
-    if (hostInfo?.result.email) setEmail(hostInfo.result.email);
-    if (hostInfo?.result.channelDescription) setChannelDescription(hostInfo.result.channelDescription);
+    if (hostInfo?.result.email) setEmail(hostInfo.result.email);
+    if (hostInfo?.result.channelDescription) setChannelDescription(hostInfo.result.channelDescription);
+    // 또는 기본값 설정
+    // setEmail(hostInfo?.result.email || '');
+    // setChannelDescription(hostInfo?.result.channelDescription || '');
  }, [hostInfo]);
src/entities/host/ui/HostInfo.tsx (1)

2-2: 함수명 오타 발견

formatProfilName 함수명에 오타가 있는 것으로 보입니다. formatProfileName이 올바른 명명이 아닌지 확인해보세요.

관련 유틸리티 함수 파일에서도 동일한 오타가 있는지 확인이 필요합니다.

Also applies to: 20-20

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 70de4d0 and b14b873.

⛔ Files ignored due to path filters (1)
  • public/assets/event-manage/details/Clock.svg is excluded by !**/*.svg
📒 Files selected for processing (11)
  • src/entities/host/ui/HostEditForm.tsx (1 hunks)
  • src/entities/host/ui/HostInfo.tsx (1 hunks)
  • src/entities/host/ui/MemberInvite.tsx (1 hunks)
  • src/entities/user/ui/BookmarkList.tsx (1 hunks)
  • src/features/host/hook/useHostInfoHook.ts (2 hunks)
  • src/features/ticket/model/ticketInformation.ts (1 hunks)
  • src/pages/event/ui/host/HostCreationPage.tsx (1 hunks)
  • src/pages/menu/ui/myHost/HostEditPage.tsx (2 hunks)
  • src/shared/hooks/useImageUpload.ts (2 hunks)
  • src/shared/lib/formValidation.ts (2 hunks)
  • src/widgets/event/ui/TicketInfo.tsx (3 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: xaexunxang
PR: GoTogether-Inc/frontend#106
File: src/entities/event/model/eventRequest.ts:26-30
Timestamp: 2025-04-29T10:26:21.217Z
Learning: GoTogether 프로젝트의 이벤트 API에서는 생성(EventCreate)과 수정(EventUpdate) 인터페이스에서 다른 필드명을 사용합니다:
- EventCreate: organizerEmail, organizerPhoneNumber (Swagger 스펙 기준)
- EventUpdate: hostEmail, hostPhoneNumber (Notion 스펙 기준)
이는 백엔드 API 명세의 불일치로 인한 의도적인 차이입니다.
src/shared/lib/formValidation.ts (1)
Learnt from: xaexunxang
PR: GoTogether-Inc/frontend#106
File: src/entities/event/model/eventRequest.ts:26-30
Timestamp: 2025-04-29T10:26:21.217Z
Learning: GoTogether 프로젝트의 이벤트 API에서는 생성(EventCreate)과 수정(EventUpdate) 인터페이스에서 다른 필드명을 사용합니다:
- EventCreate: organizerEmail, organizerPhoneNumber (Swagger 스펙 기준)
- EventUpdate: hostEmail, hostPhoneNumber (Notion 스펙 기준)
이는 백엔드 API 명세의 불일치로 인한 의도적인 차이입니다.
🧬 Code Graph Analysis (1)
src/entities/host/ui/HostInfo.tsx (2)
src/entities/host/model/hostChannelInfo.ts (1)
  • HostChannelInfoResponse (5-14)
src/shared/lib/formatProfileName.ts (1)
  • formatProfilName (1-4)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: storybook
🔇 Additional comments (15)
src/features/ticket/model/ticketInformation.ts (1)

20-21: 인터페이스 확장이 적절합니다.

ReadTicketResponse 인터페이스에 startDateendDate 필드를 추가한 것이 티켓 구매 가능 기간 표시 기능을 위해 적절하게 구현되었습니다. 타입 정의가 명확하고 기존 인터페이스 구조와 일관성을 유지하고 있습니다.

src/widgets/event/ui/TicketInfo.tsx (1)

129-137: 구매 가능기간 표시 기능이 잘 구현되었습니다.

새로운 UI 섹션이 깔끔하게 디자인되었고, 시계 아이콘과 함께 사용자에게 명확한 정보를 제공합니다. 접근성을 위한 alt 텍스트도 적절히 추가되었습니다.

src/shared/lib/formValidation.ts (1)

12-12: 코드 스타일 개선이 적절합니다.

trailing comma 추가는 코드 일관성을 개선하는 좋은 변경사항입니다.

src/pages/event/ui/host/HostCreationPage.tsx (1)

59-68: 컴포넌트 언마운트 시 상태 초기화 로직이 적절합니다.

메모리 누수 방지를 위한 cleanup useEffect가 잘 구현되어 있습니다.

src/entities/user/ui/BookmarkList.tsx (2)

12-12: 정렬 로직 제거 의도 확인 필요

ID 기준 정렬을 제거하면 데이터 표시 순서가 변경될 수 있습니다. 이것이 의도된 변경인지 확인이 필요합니다.

북마크 데이터의 기본 정렬 순서가 의도한 순서인지 확인하세요. 만약 최신 북마크를 먼저 표시해야 한다면 다음과 같이 수정할 수 있습니다:

-const visibleEvents = data.slice(0, 2);
+const visibleEvents = data.slice(0, 2); // 또는 원하는 정렬 로직 적용

11-11: BookmarkList 컴포넌트 사용처 및 정렬 로직 검토 요청

• BookmarkList는 src/pages/menu/ui/MyPage.tsx에서만 사용되고 있어, 부모가 배열을 기대해 발생하는 브레이킹 체인지는 없습니다.
• React 컴포넌트로서 if (!data) return null;는 안전하나, 빈 컨테이너(예: <ul/>) 대신 완전히 렌더링되지 않는 점이 UX에 영향을 줄 수 있으니 확인이 필요합니다.
• 정렬(.sort)을 제거하고 바로 .slice만 수행함에 따라, 백엔드 API에서 반환되는 원본 순서가 곧 사용자에게 보여질 순서가 됩니다.
조치: 서버 쿼리나 그리기 순서가 의도한 대로 정렬된 상태인지 검증해 주세요.

src/features/host/hook/useHostInfoHook.ts (1)

8-8: useHostInfoSave 훅 사용처 모두 업데이트 완료

모든 호출자가 새로운 시그니처(hostChannelId, hostInfo, email, channelDescription)에 맞게 변경되었음을 확인했습니다. 변경사항을 승인합니다.

src/shared/hooks/useImageUpload.ts (1)

4-4: 로컬 asset 사용으로 개선되었습니다.

하드코딩된 URL 대신 로컬 이미지 asset을 사용하는 것은 좋은 개선사항입니다.

하지만 HostCreationPage.tsx에서는 basicProfile 사용을 제거하여 일관성이 부족합니다. 전체 애플리케이션에서 기본 프로필 이미지 처리 방식을 통일하는 것이 좋겠습니다.

Also applies to: 22-24

Likely an incorrect or invalid review comment.

src/entities/host/ui/MemberInvite.tsx (2)

5-13: 깔끔한 컴포넌트 구조

Props 타입이 명확하게 정의되어 있고, 컴포넌트의 책임이 잘 분리되어 있습니다. 인라인 타입 정의도 적절합니다.


18-22: 사용자 친화적인 안내 메시지

멤버 추가 및 삭제 방법에 대한 명확한 안내가 제공되어 있어 좋습니다.

src/entities/host/ui/HostInfo.tsx (2)

5-11: 안전한 옵셔널 체이닝 사용

hostInfo props를 옵셔널로 받고 적절히 옵셔널 체이닝을 사용하여 안전하게 처리하고 있습니다.


15-26: 효율적인 멤버 목록 렌더링

멤버 목록을 map으로 렌더링하면서 key prop을 적절히 설정하고, ProfileCircle 컴포넌트에 필요한 props를 전달하고 있습니다.

src/pages/menu/ui/myHost/HostEditPage.tsx (3)

6-8: 성공적인 컴포넌트 분리

호스트 정보 관련 UI를 HostInfo, HostEditForm, MemberInvite 컴포넌트로 적절히 분리하여 코드의 가독성과 유지보수성을 향상시켰습니다.


59-66: 깔끔한 조건부 렌더링

각 탭에 따라 적절한 컴포넌트를 렌더링하고 있으며, props 전달도 올바르게 수행되고 있습니다.


29-32: 일관된 이벤트 핸들러 유지

handleInviteMembers 함수를 페이지 레벨에서 관리하고 하위 컴포넌트로 전달하는 방식이 적절합니다.

Comment on lines +133 to +134
구매 가능기간: {new Date(ticket.startDate).toLocaleDateString()} ~{' '}
{new Date(ticket.endDate).toLocaleDateString()}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

날짜 로케일 설정을 명시적으로 지정해주세요.

toLocaleDateString()을 사용할 때 한국 로케일을 명시적으로 지정하여 일관된 날짜 형식을 보장하는 것이 좋습니다.

다음과 같이 수정하는 것을 권장합니다:

-                구매 가능기간: {new Date(ticket.startDate).toLocaleDateString()} ~{' '}
-                {new Date(ticket.endDate).toLocaleDateString()}
+                구매 가능기간: {new Date(ticket.startDate).toLocaleDateString('ko-KR')} ~{' '}
+                {new Date(ticket.endDate).toLocaleDateString('ko-KR')}
🤖 Prompt for AI Agents
In src/widgets/event/ui/TicketInfo.tsx around lines 133 to 134, the usage of
toLocaleDateString() does not specify the locale, which can lead to inconsistent
date formats. Fix this by explicitly passing 'ko-KR' as the locale argument to
toLocaleDateString() for both startDate and endDate to ensure consistent Korean
date formatting.

channelDescription: z.string().min(5, '채널 설명은 최소 두 글자 이상이어야 합니다.'),
});
export const myPageSchema = formSchema.pick({ name: true, phone: true });
export const hostInfoSchema = formSchema.pick({ email: true });
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

타입 정의 누락

새로운 hostInfoSchema에 대한 타입 정의가 누락되었습니다. 다른 스키마들과 일관성을 위해 타입을 추가해야 합니다.

다음 diff를 적용하여 타입 정의를 추가하세요:

export type FormData = z.infer<typeof formSchema>;
export type OrganizerFormData = z.infer<typeof organizerFormSchema>;
export type EventTitleFormData = z.infer<typeof eventTitleSchema>;
export type HostCreationFormData = z.infer<typeof hostCreationSchema>;
+export type HostInfoFormData = z.infer<typeof hostInfoSchema>;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
export const hostInfoSchema = formSchema.pick({ email: true });
export type FormData = z.infer<typeof formSchema>;
export type OrganizerFormData = z.infer<typeof organizerFormSchema>;
export type EventTitleFormData = z.infer<typeof eventTitleSchema>;
export type HostCreationFormData = z.infer<typeof hostCreationSchema>;
export type HostInfoFormData = z.infer<typeof hostInfoSchema>;
🤖 Prompt for AI Agents
In src/shared/lib/formValidation.ts at line 24, the new hostInfoSchema is
missing a type definition. To maintain consistency with other schemas, define
and export a corresponding TypeScript type for hostInfoSchema using the
appropriate utility (e.g., infer or type alias) from the form validation
library. Add this type definition immediately after the schema declaration.

alt="기본 프로필 이미지"
className="w-24 h-24 object-cover rounded-full"
/>
<img src={previewUrl || ''} alt="기본 프로필 이미지" className="w-24 h-24 object-cover rounded-full" />
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

프로필 이미지 처리 일관성 문제

빈 문자열을 사용하면 깨진 이미지 아이콘이 표시될 수 있습니다. useImageUpload.ts에서는 basicProfile을 기본 이미지로 사용하는데, 여기서는 제거하여 일관성이 부족합니다.

다음 중 하나의 방식으로 해결하세요:

  1. 기본 이미지를 사용하는 방식:
+import basicProfile from '../../../../../public/assets/event-manage/creation/BasicProfile.png';
-<img src={previewUrl || ''} alt="기본 프로필 이미지" className="w-24 h-24 object-cover rounded-full" />
+<img src={previewUrl || basicProfile} alt="기본 프로필 이미지" className="w-24 h-24 object-cover rounded-full" />
  1. 또는 이미지가 없을 때 placeholder 컴포넌트 사용:
-<img src={previewUrl || ''} alt="기본 프로필 이미지" className="w-24 h-24 object-cover rounded-full" />
+{previewUrl ? (
+  <img src={previewUrl} alt="기본 프로필 이미지" className="w-24 h-24 object-cover rounded-full" />
+) : (
+  <div className="w-24 h-24 bg-gray-200 rounded-full flex items-center justify-center">
+    <span className="text-gray-500">이미지</span>
+  </div>
+)}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<img src={previewUrl || ''} alt="기본 프로필 이미지" className="w-24 h-24 object-cover rounded-full" />
// Add to the top of src/pages/event/ui/host/HostCreationPage.tsx
import basicProfile from '../../../../../public/assets/event-manage/creation/BasicProfile.png';
// …
// Replace the existing <img> line at around line 73:
<img
src={previewUrl || basicProfile}
alt="기본 프로필 이미지"
className="w-24 h-24 object-cover rounded-full"
/>
🤖 Prompt for AI Agents
In src/pages/event/ui/host/HostCreationPage.tsx at line 73, the img tag uses an
empty string as the fallback for the src attribute, causing broken image icons
when no previewUrl is available. To fix this, replace the empty string fallback
with the default image URL (basicProfile) used in useImageUpload.ts to maintain
consistency, or alternatively, conditionally render a placeholder component when
previewUrl is not present instead of rendering an img with an empty src.

Comment on lines +39 to +46
<TertiaryButton
type="button"
label="수정하기"
size="large"
color="pink"
onClick={handleSave}
disabled={!emailValidation.success}
/>
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

중복된 저장 기능 개선 필요

두 개의 저장 버튼이 동일한 handleSave 함수를 호출하고 있습니다. 각각의 필드에 대해 독립적인 저장 기능을 제공하거나, 하나의 통합된 저장 버튼을 사용하는 것이 더 나은 UX를 제공할 수 있습니다.

이메일 필드에만 유효성 검사를 적용하고 있는 것도 일관성 측면에서 검토가 필요합니다.

Also applies to: 55-55

🤖 Prompt for AI Agents
In src/entities/host/ui/HostEditForm.tsx around lines 39 to 46 and line 55,
there are two save buttons both calling the same handleSave function, which
causes redundant saving behavior. Refactor the code to either provide
independent save functions for each field or consolidate into a single save
button to improve UX. Additionally, review and apply consistent validation logic
across all relevant fields, not just the email field, to maintain uniform
validation standards.

const [channelDescription, setChannelDescription] = useState('');

const { data: hostInfo } = useHostChannelInfo(hostChannelId);
const { handleSave } = useHostInfoSave(hostChannelId, hostInfo!, email, channelDescription);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

위험한 Non-null assertion 사용

hostInfo!와 같은 non-null assertion 사용은 hostInfoundefined일 때 런타임 오류를 발생시킬 수 있습니다. 조건부 렌더링이나 적절한 기본값 처리를 고려해보세요.

-  const { handleSave } = useHostInfoSave(hostChannelId, hostInfo!, email, channelDescription);
+  const { handleSave } = useHostInfoSave(hostChannelId, hostInfo, email, channelDescription);

또는 컴포넌트 전체를 조건부로 렌더링하는 방식을 고려하세요.

🤖 Prompt for AI Agents
In src/entities/host/ui/HostEditForm.tsx at line 18, the non-null assertion
operator (!) is used on hostInfo, which can cause runtime errors if hostInfo is
undefined. To fix this, add a conditional check to ensure hostInfo is defined
before calling useHostInfoSave, or provide a safe default value for hostInfo.
Alternatively, wrap the entire component or relevant parts in a conditional
rendering block that only renders when hostInfo is available.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🪄 Refactoring 코드 리팩토링

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[refactor] 호스트&티켓 페이지 리팩토링

3 participants